package monitor;

import java.util.Date;

import jess.JessException;

import monitor.basic.Activity;
import monitor.basic.Monitor;
import monitor.inference.InferenceEngine;
import monitor.transmission.Transmitter;

import socio.hardware.Urinal;
import socio.initiative.Human;

public aspect UrinalMonitor extends Monitor {

	public UrinalMonitor() {
		super();
		try {
			InferenceEngine engine = new InferenceEngine(null, null);
			Transmitter transmitter = new Transmitter();
			this.setTransmitter(transmitter);
			this.setEngine(engine);
			this.start();
		} catch (JessException e) {
			e.printStackTrace();
		}
	}

	before(Urinal urinal, Human who, Date when): 
		execution(void Urinal.piss(Human,Date))
		&&target(urinal)
		&&args(who,when) 
	{
		Activity activity = new Activity(who, "toPiss", urinal, when);
		this.recorder.record(activity);
		this.recorder.record("[" + when + "]" + who.getId() + " is to piss");
	}

	after(Urinal urinal, Human who, Date when) returning() : 
		execution(void Urinal.piss(Human,Date))
		&&target(urinal)
		&&args(who,when) 
	{
		Activity activity = new Activity(who, "pissed", urinal, when);
		this.recorder.record(activity);
		this.recorder.record("[" + when + "]" + who.getId() + " has pissed");
	}
}
